function [stforc,yforc]=forecastLoop(GBook,RBook,ZBook,CBook,genTauVec,stateJump,innovMat,Nforc)
%% Key is that genTauVec, vector indicating which page to use, must match
%% Nforc!!!
Ns=length(stateJump(:));
%% If Pass in InnovMat, generate forecasts using that Matrix
if ~isempty(innovMat)
    dim=size(innovMat);
    if dim(1)~=Nforc
        error('EMAT Matrix of shocks must be [NFORC NX]')
    end
    flag_useShocks=1;
else
    flag_useShocks=0;
end
if length(genTauVec)~=Nforc;
    error('genTauVec must match number of forecasts');
end

% Define matrices
stforc=zeros(Ns,Nforc);
yforc =zeros(size(ZBook(:,:,genTauVec(1)),1),Nforc);

% Fill in first state
switch flag_useShocks
    case 0
        stforc(:,1)=GBook(:,:,genTauVec(1))*stateJump(:);
    case 1
        stforc(:,1)=GBook(:,:,genTauVec(1))*stateJump(:) + ...
            RBook(:,:,genTauVec(1))*( innovMat(1,:)' ) ;
end
yforc( :,1)=ZBook(:,:,genTauVec(1))*(CBook(:,genTauVec(1))+stforc(:,1) );

for ii=2:Nforc;
    switch flag_useShocks
        case 0
            stforc(:,ii)=GBook(:,:,genTauVec(ii))*stforc(:,ii-1);
        case 1
            stforc(:,ii)=GBook(:,:,genTauVec(ii))*stforc(:,ii-1) + RBook(:,:,genTauVec(ii))*( innovMat(ii,:)' ) ;
    end
    yforc(:, ii)=ZBook(:,:,genTauVec(ii))*(CBook(:,genTauVec(ii))+stforc(:,ii) );
end
stforc=stforc';
yforc =yforc' ;